Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ethjs-unit

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethjs-unit

A simple module for handling Ethereum units (e.g. 'ether', 'wei', etc...)

  • 0.1.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
490K
increased by14.54%
Maintainers
1
Weekly downloads
 
Created

What is ethjs-unit?

The ethjs-unit npm package is a utility library for Ethereum that provides functions to convert between different Ethereum units. It is particularly useful for developers working with Ethereum smart contracts and dApps, as it simplifies the process of handling various units of Ether and other Ethereum-based tokens.

What are ethjs-unit's main functionalities?

Convert Ether to Wei

This feature allows you to convert Ether to Wei, which is the smallest unit of Ether. The code sample demonstrates converting 1 Ether to Wei.

const ethjsUnit = require('ethjs-unit');
const weiValue = ethjsUnit.toWei(1, 'ether');
console.log(weiValue); // '1000000000000000000'

Convert Wei to Ether

This feature allows you to convert Wei back to Ether. The code sample demonstrates converting 1,000,000,000,000,000,000 Wei to 1 Ether.

const ethjsUnit = require('ethjs-unit');
const etherValue = ethjsUnit.fromWei('1000000000000000000', 'ether');
console.log(etherValue); // '1'

Convert between other units

This feature allows you to convert between various other units such as Gwei, Kwei, Mwei, etc. The code sample demonstrates converting 1 Gwei to Wei and back.

const ethjsUnit = require('ethjs-unit');
const gweiValue = ethjsUnit.toWei(1, 'gwei');
console.log(gweiValue); // '1000000000'
const etherFromGwei = ethjsUnit.fromWei('1000000000', 'gwei');
console.log(etherFromGwei); // '1'

Other packages similar to ethjs-unit

Keywords

FAQs

Package last updated on 20 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc